<template>
  <div class="container-layer-my">
    <div class="head-info">
      <div class="left-info">
        <div class="head-img">
          <van-image
            :src="userInfo.avatar || avatar"
            width="80"
            height="80"
            fit="cover"
            round
          />
        </div>
        <div class="more-info">
          <div style="width: 200px;">
            <span class="name">{{ userInfo.nickname ||'多哈哈' }}</span>
            <span>
              <img :src="userInfo.gender | sex" alt class="boy-icon">
            </span>
          </div>
          <div class="age-constell">
            <span class="age">25岁</span>
            <span class="constell">{{ computXingzuo.name }}</span>
          </div>
        </div>
      </div>
      <div class="info-right">
        <div>{{ computBumen.name }}</div>
      </div>
    </div>
    <div class="words" :class="`words-${userInfo.gender}`">
      <div class="words-cont">
        <img src="@/assets/heart.png" alt class="heart">
        <div class="ss">{{ userInfo.bio || '希望我的另一半阳光、爱运动，如果还会做饭就更好啦' }}</div>
      </div>
    </div>
  </div>
</template>

<script>
// icon
import avatar from '@/assets/tx.png'
import girl from '@/assets/girl-icon.png'
import boy from '@/assets/boy-icon.png'
import { mapGetters } from 'vuex'
export default {
  filters: {
    sex(sex) {
      const sexMap = {
        1: boy,
        2: girl,
        3: '未知'
      }
      return sexMap[sex]
    }
  },
  props: {
    userInfo: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      loading: true,
      avatar
    }
  },
  computed: {
    ...mapGetters([
      'xingzuo',
      'bumen'
    ]),
    computXingzuo() {
      return this.xingzuo.find(obj => obj.id === this.userInfo.constellation) || {}
    },
    computBumen() {
      return this.bumen.find(obj => obj.id === this.userInfo.department_id) || {}
    }
  }
}
</script>

<style lang="less" scoped>
.container-layer-my {
    padding: 2.5%;
    margin-top:2vw;
}
.head-info,
.left-info {
  display: flex;
  justify-content: space-between;
}
.more-info {
  width: 50%;
  box-sizing: border-box;
  padding-left: 15px;
  padding-top: 20px;
}
.left-info {
  width: 50%;
}
.head-img .tx {
  width: 100%;
}
.age,
.constell {
  font-size: 0.9rem;
}
.age-constell{
  display:inline-block;
   width:200px;
   padding-top: 5px;
}
.constell {
  margin-left: 9%;
}
.name {
  font-size: 1.2rem;
  font-weight: bold;
}
.info-right {
  font-size:0.75rem ;
  // font-size:16px ;
  color: #666;
}
.boy-icon{
  width: 15px;
  height: 15px;
  padding-left: 5px
}
.ss{
  padding-right: 5px;
}
</style>

<style lang="less" scoped>
.words {
  width: 100%;
  margin: 5% 0;
  position: relative;
  border-radius: 10px;
  display: inline-block;
  // font-size: 0.75rem;
  font-size: 1rem;
  line-height: 28px;
  background: #6392ea;
  color: #fff;
  &:after {
    content: " ";
    position: absolute;
    top: -9px;
    left: 15px;
    border-bottom: 12px solid #6392ea;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
  }
  .heart {
    width: 16px;
    height: 14px;
    line-height: 14px;
    padding: 4px 15px;
  }
  .words-cont {
    padding: 10px 0;
    // letter-spacing: 3px;
    line-height: 20px;
    display: flex;
    justify-content: flex-start;
  }
  &-2 {
    background: #ef8383;
    &::after {
      border-bottom-color: #ef8383;
    }
  }
  &-3 {
    background: #f45050;
    &::after {
      border-bottom-color: #f45050;
    }
  }
}
</style>
